<?php
/**
 * Created by PhpStorm.
 * User: edmmss
 * Date: 2019/1/28
 * Time: 09:43
 */

namespace app\modules\repository;


class Post
{
    private $_id;

    private $_title;

    private $_text;

    public function __construct($id, string $title, string $text)
    {
        $this->_id = $id;
        $this->_title = $title;
        $this->_text = $text;
    }

    public static function fromState(array $state): Post
    {
        return new self($state['id'], $state['title'], $state['text']);
    }

    /**
     * @return mixed
     */
    public function getId()
    {
        return $this->_id;
    }

    /**
     * @param mixed $id
     */
    public function setId($id): void
    {
        $this->_id = $id;
    }

    /**
     * @return string
     */
    public function getTitle(): string
    {
        return $this->_title;
    }

    /**
     * @param string $title
     */
    public function setTitle(string $title): void
    {
        $this->_title = $title;
    }

    /**
     * @return string
     */
    public function getText(): string
    {
        return $this->_text;
    }

    /**
     * @param string $text
     */
    public function setText(string $text): void
    {
        $this->_text = $text;
    }
}